package;

import js.Browser.*;
import lib.THREE;
import lib.THREE.*;
import lib.Stats;

class Main {
	static public function main() {
		var scene = new Scene();
		var camera = new PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 1000);
		camera.position.z = 400;

		var render = new WebGLRenderer({antialias: true});
		render.setSize(window.innerWidth, window.innerHeight);
		render.setPixelRatio(window.devicePixelRatio);

		var texture = new TextureLoader().load('https://threejs.org/examples/textures/crate.gif');
		var box = new Mesh(new BoxBufferGeometry(200, 200, 200), new MeshBasicMaterial({map: texture}));
		scene.add(box);

		document.body.appendChild(render.domElement);

		var _render = null;

		var stats = new Stats();
		document.body.appendChild(stats.dom);

		function _render(?f:Float):Void {
			stats.begin();
			box.rotation.x += 0.005;
			box.rotation.y += 0.01;
			render.render(scene, camera);
			stats.end();
			window.requestAnimationFrame(_render);
		}

		

		_render();
	}
}
